package com.newsproject.mapper;

import com.newsproject.pojo.DTO.PostDTO;
import com.newsproject.pojo.vo.CommentVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface PostMapper {

    //根据新闻id和用户id查看是否点赞
    Integer selectLikeStatusByPostIdAndUserId(@Param("post_id") Integer postId, @Param("user_id") Integer userId);
    //查看用户是否关注了作者

    Integer selectFollowOrNotByUserIdAndAuthorId(@Param("postId") Integer postId, @Param("userId") Integer userId);
    //查看用户是否收藏了文章
    @Select("select count(*) from bookmark where user_id = #{user_id} and post_id = #{post_id}")
    Integer selectBookmarkOrNotByUserIdAndPostId(@Param("post_id") Integer postId,@Param("user_id") Integer userId );
    List<CommentVo> selectAllCommentByPostId(@Param("post_id")int postId,@Param("start")int startIndex);
    Integer selectCommentCountByPostId(@Param("post_id")int postId);


    //分页查询文章
    List<PostDTO> findPost(Map<String,Object> param);

    int totalCount(Map<String, Object> param);

}
